package com.gjl.lib;

import java.util.Properties;
import java.io.*;
import java.text.*;

public class Configuration {

	/**
	 * @param args
	 */
	private static Properties pro = new Properties();	
	static {
		InputStream in =   Configuration.class.getResourceAsStream("/Properties.properties"); 
		try{		
			pro.load(in);
			in.close();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		//Configuration c = new Configuration();
		System.out.println("In main"+Configuration.getCharset());
	}
		
	public static String getProperty(String key, String defaultValue){		
		return pro.getProperty(key, defaultValue);
	}
	
	
	public static String getProperty(String key){		
		String r = getProperty(key,"#defaultEmtpy#");
		if(r.equals("#defaultEmtpy#")){
			System.err.println("Couldn't found the property of :"+key);
		}		
		return r;
		
	}
	

	public static String getIndexLawServer(){
		return getProperty("IndexServerOfLaw");
	}
	public static int getIndexLawPort(){
		//Integer.parseInt(s)
		return Integer.parseInt(getProperty("IndexPortOfLaw"));
	}
	public static String getIndexCaseServer(){
		return getProperty("IndexServerOfCase");
	}
	public static int getIndexCasePort(){
		return Integer.parseInt(getProperty("IndexPortCase"));
	}
	
	public static String getCharset(){
		String key = "defaultCharset";
		return getProperty(key);
	}
	
	public static String getDB_URL(){
		return "jdbc:mysql://"+getProperty("gbl_db_host")+"/"+getProperty("gbl_db_name");
	}
		
	public static String getDB_UserName(){
		return getProperty("gbl_db_user");
	}
	
	public static String getDB_PassWD(){
		return getProperty("gbl_db_passwd");
	}

}
